<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
        <el-form-item label="用户电话" prop="phonenumber">
          <el-input v-model="queryParams.phonenumber" placeholder="请输入用户电话" clearable size="small"
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="充值时间" prop="createTime">
          <el-date-picker @change="createTimeChange" v-model="createTime" type="daterange" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
                </el-date-picker>
        </el-form-item>
        <el-form-item label="充值金额" prop="chongzhiJine">
          <el-input v-model="queryParams.chongzhiJine" placeholder="请输入充值金额" clearable size="small"
            @keyup.enter.native="handleQuery" ><div slot="append">元</div></el-input>
        </el-form-item>
        <el-form-item label="技师推荐码" prop="tuijianMa">
          <el-input v-model="queryParams.tuijianMa" placeholder="请输入技师推荐码" clearable size="small"
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="付款方式" prop="payType">
          <el-select v-model="queryParams.payType" placeholder="请选择付款方式">
            <el-option v-for="contract in payChannelArray" :key="contract.dictValue" :label="contract.dictLabel"
              :value="contract.dictValue"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <div>已收：¥{{ sum }} 元</div>
      <el-table v-loading="loading" :data="tabList" >
        <el-table-column label="用户电话" align="center" prop="phonenumber" />
        <el-table-column label="充值时间" align="center" prop="tradeTime" />
        <el-table-column label="充值金额" align="center" prop="chongzhiJine" />
        <el-table-column label="赠送金额" align="center" prop="zengsongJine" />
        <el-table-column label="实际到账金额" align="center" prop="changeBalance" />
        <el-table-column label="技师推荐码" align="center" prop="tuijianMa" />
        <el-table-column label="付款方式" align="center" prop="payType" :formatter="payTypeformatter"/>
        <el-table-column label="银联单号" align="center" prop="tradeId" />
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
  </template>
    
  <script>
  import { chongzhilist } from "@/api/collectionBill/collectionBill";
  import { getToken } from '@/utils/auth'
  export default {
    name: "Knowledge",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 表格数据
        tabList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        companyTypeOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          realName:null,
          phonenumber:null,
          chongzhiJine:null,
          tuijianMa:null,
          payType:null,
          createTime:null
        },
        createTime:'',
        czbeginTime: '',
        czendTime: '',
        payChannelArray:[],//付款方式
        sum:'0'
      };
    },
    created() {
      this.getList();
      //在字典查询
      //付款方式
      this.getDicts("pay_channel").then(response => {
        this.payChannelArray = response.data;
      });
    },
    methods: {
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.queryParams.czbeginTime = this.czbeginTime;
        this.queryParams.czendTime = this.czendTime;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.createTime = ''
        this.czbeginTime = ''
        this.czendTime = ''
        this.resetForm("queryForm");
        this.handleQuery();
      },
      //下单时间
      createTimeChange() {
        this.czbeginTime = this.createTime[0] 
        this.czendTime = this.createTime[1]
      },
      /** 查询产品入库列表 */
      getList() {
        this.loading = true;
        chongzhilist(this.queryParams).then(response => {
          this.tabList = response.rows;
          this.total = response.total;
          this.sum = response.sum;
          this.loading = false;
        });
      },
      //付款方式
      payTypeformatter(row, column) {
        return this.selectDictLabel(this.payChannelArray, row.payType);
      },
    }
  };
  </script>
  <style>
  </style>
    